/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { Request, Response } from 'express';
import { ResponseItem, responseSuccess } from '../utils';
import Mock from 'mockjs';

export default {
  'POST /jdk/order/list': (req: Request, res: Response) => {
    const { page = 1, pageSize = 20 } = req.body;
    const data = Mock.mock({
      [`list|${pageSize}`]: [
        {
          account: '13783636924_account',
          created_at: '@date',
          delivery_accept_time: '@date()',
          'delivery_brand_name|1': ['美团', '饿了么', '京东'],
          delivery_order_no: '15326283',
          id: '@id',
          'order_desc|1': [
            '待接单',
            '取货中',
            '配送中',
            '已完成',
            '已取消',
            '预约单',
            '异常',
            '其他平台已完成',
          ],
          receiver_address: '@county(true)',
          shop_name: '@cname(3)',
          source_brand_name: '快宝',
          source_order_no: 'source_order_no_外卖单号',
          sh_phone: 'sh_phone_13388887777',
        },
      ],
      page,
      pageSize,
      total: 100,
    });

    let result: ResponseItem = {
      code: 0,
      msg: '成功',
      data,
    };
    return res.json(result);
  },
  'POST /jdk/order/detail': (req: Request, res: Response) => {
    let result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: Mock.mock({
        task_order_id: '2071202624430164801',
        task_order_ids: ['2071202624430164801', '2071202624430164802'],
        delivery_log: [
          {
            brand_name: '顺丰同城',
            delivery_no: '@id',
            delivery_account: '7373838',
            cancel: [],
            create: {
              created_at: '2022-09-27 14:38:51',
              log_desc: '发单',
            },
            delivery_type: '0',
            orderback: [
              {
                created_at: '2022-09-27 14:38:51',
                log_desc: '发单',
              },
              {
                created_at: '2022-09-26 14:38:51',
                log_desc: '发单',
              },
              {
                created_at: '2022-09-25 14:38:51',
                log_desc: '发单',
              },
            ],
            status_desc: '已完成',
            'status|1': [-1, 0, 1, 2, 3, 4, 5, 6, 7],
            order_id: '2070928356600806401',
            delivery_brand: 'ddks',
          },
          {
            brand_name: '曹操送',
            delivery_no: '@id',
            cancel: [],
            create: {
              created_at: '2022-09-27 14:39:21',
              log_desc: '发单',
            },
            delivery_type: '0',
            orderback: [],
            status_desc: '已取消',
            delivery_brand: 'apt',
            order_id: '2070928356600806401',
            'status|1': [-1, 0, 1, 2, 3, 4, 5, 6, 7],
          },
        ],
        operate: [
          {
            created_at: '2022-09-27 14:38:44',
            id: '16662',
            info: '自建订单【即时单】',
            order_id: '709275272404061',
            user_id: '124321649',
          },
          {
            created_at: '2022-09-27 14:38:50',
            id: '16663',
            info: '手动发单【待接单】',
            order_id: '709275272404061',
            user_id: '124321649',
          },
          {
            created_at: '2022-09-27 14:39:31',
            id: '16669',
            info: '顺丰同城骑手:王康(15002121728)已接单【取货中】',
            order_id: '709275272404061',
            user_id: '0',
          },
          {
            created_at: '2022-09-27 14:42:07',
            id: '16675',
            info: '顺丰同城骑手已到店【取货中】',
            order_id: '709275272404061',
            user_id: '0',
          },
          {
            created_at: '2022-09-27 14:44:43',
            id: '16676',
            info: '顺丰同城骑手已取货【配送中】',
            order_id: '709275272404061',
            user_id: '0',
          },
          {
            created_at: '2022-09-27 14:58:28',
            id: '16684',
            info: '顺丰同城骑手完成配送【已完成】',
            order_id: '709275272404061',
            user_id: '0',
          },
          {
            created_at: '2022-09-27 14:58:28',
            id: '16685',
            info: '发单支出7.24元（运费:7.24元/小费:0元）【平台运力】',
            order_id: '709275272404061',
            user_id: '0',
          },
        ],
        order: {
          account: '18217690146',
          booking: '否',
          created_at: '2022-09-27 14:38:44',
          delivery_accept_time: '2022-09-27 14:39:31',
          delivery_brand_name: '顺丰同城',
          delivery_order_no: '3490207722513651713',
          delivery_type: '否',
          'distance|1': ['2461', '92', '10929'],
          good_info: '货物价格5000分 重量1000克',
          id: '709275272404061',
          league_id: '是',
          league_name: '',
          order_remark: '',
          sh_info: '2号线朱测试18217690146',
          shop_info: '新泾镇通协路269号建滔广场6号楼6楼A单元18217690147',
          shop_name: 'zm测试小店',
          source_brand_name: '快宝',
          source_name: '快宝',
          source_order_no: '',
          'order_desc|1': ['已完成', '已取消'],
          sender_address: '@county(true)',
          sender_name: '@cname',
          sender_phone: '@phone',
          'delivery_fee_list|1-3': [
            {
              frequency: '1',
              amount: '1500',
              created_at: '2023-07-31 11:29:00',
            },
          ],
        },
        payLog: [
          {
            created_at: '2022-09-27 14:38:44',
            desc: '余额 支付 724分',
          },
        ],
      }),
    };
    return res.json(result);
  },
  'POST /jdk/order/cancelByDeliveryBrand': (req: Request, res: Response) =>
    responseSuccess(req, res),
  'POST /jdk/order/editOrderDelivery': (req: Request, res: Response) => responseSuccess(req, res),
};
